from django.shortcuts import render

# Create your views here.
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from rest_framework.mixins import (
    CreateModelMixin,
    ListModelMixin,
    DestroyModelMixin
)
from .models import *
from .myserlalizers import BookSerializers


class BooksView(GenericAPIView, CreateModelMixin, ListModelMixin, DestroyModelMixin):
    queryset = Books.objects.all()
    serializer_class = BookSerializers

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)

    def post(self, request, *args, **kwargs):
        return self.create(request, *args, **kwargs)


class Del(GenericAPIView, DestroyModelMixin):
    queryset = Books.objects.all()
    serializer_class = BookSerializers

    def delete(self, request, *args, **kwargs):
        return self.destroy(request, *args, **kwargs)
